package org.tgcloud.group.web.controller.app;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.StringUtil;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.app.OtherProjectAppService;
import org.tgcloud.group.web.controller.dto.otherProject.OtherProjectAppMsgDTO;
import org.tgcloud.group.web.controller.dto.user.UserDTO;
import org.tgcloud.group.web.controller.req.order.CheckChannelUserDTO;
import org.tgcloud.group.web.controller.req.order.OrderIdReq;
import org.tgcloud.group.web.controller.req.otherProject.*;
import org.tgcloud.group.web.controller.req.user.UserAppSearchReq;

import java.util.List;

/**
 * @Author: zhy
 * @Created: 2024-06-05-上午11:46
 * @Description: 小程序-其他项目管理
 */
@Api(tags = "小程序-其他项目相关接口")
@RestController
@RequestMapping("/app/user")
@EnableAutoConfiguration
public class OtherProjectAppController extends ClientAPPBaseController{

    @Autowired
    private OtherProjectAppService otherProjectService;


    @ApiOperation(value = "新增项目")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/addAppOtherProject")
    public APPResultMessage<Object, List> doAddAppOtherProject(@ModelAttribute("session") Session session,
                                                            @RequestBody OtherProjectReq req) {
        return otherProjectService.doAddAppOtherProject(session.getUserId(),req);
    }


    @ApiOperation(value = "项目详情")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/getOtherProjectMsg")
    public APPResultMessage<OtherProjectAppMsgDTO, List> getOtherProjectMsg(@ModelAttribute("session") Session session,
                                                                            @RequestBody OtherProjectIdReq req) {
        return otherProjectService.getOtherProjectMsg(session.getUserId(),req);
    }


    @ApiOperation(value = "重置")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/doResetOtherProject")
    public APPResultMessage<Object, List> doResetOtherProject(@ModelAttribute("session") Session session,
                                                              @RequestBody OtherProjectIdReq req) {
        return otherProjectService.doResetOtherProject(session.getUserId(),req);
    }

    @ApiOperation(value = "设置截止时间")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/doSetOtherProjectEndTime")
    public APPResultMessage<Object, List> doSetOtherProjectEndTime(@ModelAttribute("session") Session session,
                                                       @RequestBody OtherProjectBiddingEndTimeReq req) {
        return otherProjectService.doSetOtherProjectEndTime(session.getUserId(),req);
    }

    @ApiOperation(value = "开拓者推送参与竞价的渠道用户")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/sureOtherProjectPushChannelUser")
    public APPResultMessage<Object, List> doSureOtherProjectPushChannelUser(@ModelAttribute("session")Session session,
                                                                @RequestBody OtherProjectChannelUserIdReq req) {
        if (StringUtil.isBlank(req.getUserIds())){
            return APPResultMessage.MISS_PARAMETER();
        }
        return otherProjectService.doSureOtherProjectPushChannelUser(session.getUserId(),req);
    }


    @ApiOperation(value = "推送用户列表")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/otherProjectUserAppList")
    public APPResultMessage<Object, UserDTO> getOtherProjectUserAppList(@ModelAttribute("session") Session session,
                                                            @RequestBody UserAppSearchReq req) {
        return otherProjectService.getOtherProjectUserAppList(session.getUserId(),req);
    }


    @ApiOperation(value = "渠道提交竞价")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/pushOtherProjectChannelPrice")
    public APPResultMessage<Object, List> doPushOtherProjectChannelPrice(@ModelAttribute("session") Session session,
                                                                        @RequestBody OtherProjectChannelPriceReq req) {
        return otherProjectService.doPushOtherProjectChannelPrice(session.getUserId(),req);
    }



    @ApiOperation(value = "渠道用户发起二次竞价")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/startOtherProjectTwoBidding")
    public APPResultMessage<Object, List> doStartOtherProjectTwoBidding(@ModelAttribute("session")Session session,
                                                            @RequestBody OtherProjectIdReq req) {
        return otherProjectService.doStartOtherProjectTwoBidding(session.getUserId(),req);
    }

    @ApiOperation(value = "渠道用户参与二次竞价")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/joinOtherProjectTwoBidding")
    public APPResultMessage<Object, List> doJoinOtherProjectTwoBidding(@ModelAttribute("session")Session session,
                                                           @RequestBody OtherProjectIdReq req) {
        return otherProjectService.doJoinOtherProjectTwoBidding(session.getUserId(),req);
    }

    @ApiOperation(value = "渠道/开拓者-拒绝竞价")
    @ApiImplicitParams({
    })
    @ResponseBody
    @PostMapping(value = "/doRefuseOtherProjectChannelOrder")
    public APPResultMessage<Object, List> doRefuseOtherProjectChannelOrder(@ModelAttribute("session")Session session,
                                                                       @RequestBody OtherProjectIdReq req) {
        return otherProjectService.doRefuseOtherProjectChannelOrder(session.getUserId(), session.getUserType(), req);
    }


}
